

#include "test_recurrence.h"


using namespace std;
using namespace tenacitas;
using namespace tenacitas::time_tests;


// **************************************
// t300000

t300000::
t300000 () :
    tenacitas::test("t300000",
		    "Tries to create a sequence of dates using a "
		    "tenacitas::monthly_by_day where the days are 4, 7, "
		    "16, 22, the first date is 2009.06.05, every month, for two "
		    " months ") {}

t300000::
~t300000() {}

void 
t300000::
operator ( ) ( ptr<tenacitas::test_printer> print )
    throw ( fault ) {

    // to format messaged
    ostringstream s;

    // our recurrence criteria
    monthly_by_day<date> criteria (
	// what to do if a calculated date is holiday?
	monthly_by_day<date>::create_anyway,

	// what to do if a calculated date is a weekend?
	monthly_by_day<date>::create_anyway,

	// what to do if a calculated date is a date that should not be used?
	monthly_by_day<date>::dont_create,
	
	// what to do if a calculated date is an invalid date?
	monthly_by_day<date>::dont_create,

	// our list of holidays
	list<date> ( ) ) ;

    // these are the days that should be used to create dates
    criteria.add ( day ( 4 ) ) ;
    criteria.add ( day ( 7 ) ) ;
    criteria.add ( day ( 16 ) ) ;
    criteria.add ( day ( 22 ) ) ;

    // the date where the recurrence starts
    date first ( day ( 5 ), month::jun, 2009)  ;

    // the number of months of the recurrence
    u16t max_periods = 2;

    // the interval between the months
    i8t at_each = 1;

    // a little information to log
    s << "Initial value: " << first << ", "
      << "# of periods: " << max_periods << ", "
      << "at each " << static_cast<i16t>( at_each ) << " months\n";
    (*print)(s.str());
    s.str( "" ) ;

    // creating the recurrence object
    recurrence<date, monthly_by_day<date> > mr;

    // generting the list of dates
    list<date> ds = mr.generate ( first, max_periods, at_each, criteria ) ;

    // final report
    s << "The sequence generated:\n";
    
    for ( list<date>::const_iterator i = ds.begin( ) ;
	  i != ds.end( ) ;
	  ++i ) {
	s << *i << " ";
    }
    s << endl << endl;
    (*print)(s.str());
    s.str ( "" ) ;
    
    // comparing to what we wanted
    list<date> goal;
    goal.push_back ( date ( day ( 07 ) , month::jun, 2009 ) );
    goal.push_back ( date ( day ( 16 ) , month::jun, 2009 ) );
    goal.push_back ( date ( day ( 22 ) , month::jun, 2009 ) );
    goal.push_back ( date ( day ( 04 ) , month::jul, 2009 ) );
    goal.push_back ( date ( day ( 07 ) , month::jul, 2009 ) );
    goal.push_back ( date ( day ( 16 ) , month::jul, 2009 ) );
    goal.push_back ( date ( day ( 22 ) , month::jul, 2009 ) );

    if ( goal != ds )  {
	s << "Generated list is not correct. That's what we wanted:\n";
	for ( list<date>::const_iterator i = goal.begin( ) ;
	      i != goal.end( ) ;
	      ++i ) {
	    s << *i << " ";
	}
	s << endl << endl;
	(*print)(s.str());
	
	throw fault ( create_fault ( date,
				     date::date::error_processing_date ) ) ;
    }

    s << "Generated list is correct!!" << endl;
    (*print)(s.str());
}


// // **************************************
// // t300001

// t300001::
// t300001 () :
//     tenacitas::test("t300001",
// 		    "Tries to create a sequence of dates using a "
// 		    "tenacitas::monthly_by_day<date> where the days are 20 and 31, the "
// 		    "first date is 2009.02.04, every month, for 3 months") {}

// t300001::
// ~t300001() {}

// void 
// t300001::
// operator ( ) ( ptr<tenacitas::test_printer> print )
//     throw ( fault ) {

//     ostringstream s;

//     

//     monthly_by_day<date> criteria ( monthly_by_day<date>::create_anyway,
// 		      monthly_by_day<date>::create_anyway,
// 		      monthly_by_day<date>::dont_create,
// 		      monthly_by_day<date>::dont_create,
// 		      list<date> ( ) ) ;



//     criteria.add ( day ( 20 ) ) ;
//     criteria.add ( day ( 31 ) ) ;

//     date first ( day ( 4 ), month::feb, 2009)  ;

//     u16t max_periods = 3;
//     i8t at_each = 1;
    
//     s << "Initial value: " << first << ", "
//       << "# of periods: " << max_periods << ", "
//       << "at each " << static_cast<i16t>( at_each ) << " months\n";

//     (*print)(s.str());
//     s.str( "" ) ;

//     monthly_recurrence<date, monthly_by_day<date><date> > mr;

//     list<date> ds = mr.generate ( first, max_periods, at_each, criteria ) ; 
    
//     s << "The sequence generated:\n";
    
//     for ( list<date>::const_iterator i = ds.begin( ) ;
// 	  i != ds.end( ) ;
// 	  ++i ) {
// 	s << *i << " ";
//     }
//     s << endl << endl;
    
//     (*print)(s.str());
//     s.str ( "" ) ;
    

//     list<date> goal;
//     goal.push_back ( date ( day ( 20 ) , month::feb, 2009 ) );
//     goal.push_back ( date ( day ( 20 ) , month::mar, 2009 ) );
//     goal.push_back ( date ( day ( 31 ) , month::mar, 2009 ) );
//     goal.push_back ( date ( day ( 20 ) , month::abr, 2009 ) );


//     if ( goal != ds )  {
// 	s << "Generated list is not correct. That's what we wanted:\n";
// 	for ( list<date>::const_iterator i = goal.begin( ) ;
// 	      i != goal.end( ) ;
// 	      ++i ) {
// 	    s << *i << " ";
// 	}
// 	s << endl << endl;
// 	(*print)(s.str());
	
// 	throw fault ( create_fault ( date,
// 				     date::date::error_processing_date ) ) ;
//     }

//     s << "Generated list is correct!!" << endl;
//     (*print)(s.str());
// }

// // **************************************
// // t300002

// t300002::
// t300002 () :
//     tenacitas::test("t300002",
// 		    "Tries to create a sequence of dates using a "
// 		    "tenacitas::monthly_by_day<date> where the days are 4, 7, "
// 		    "16, 22, the first date is 2009.06.10, every month, for two "
// 		    "months") {}

// t300002::
// ~t300002() {}

// void 
// t300002::
// operator ( ) ( ptr<tenacitas::test_printer> print )
//     throw ( fault ) {

//     ostringstream s;

//     

//     monthly_by_day<date> criteria ( monthly_by_day<date>::create_anyway,
// 		      monthly_by_day<date>::create_anyway,
// 		      monthly_by_day<date>::dont_create,
// 		      monthly_by_day<date>::dont_create,
// 		      list<date> ( ) ) ;


//     criteria.add ( day ( 4 ) ) ;
//     criteria.add ( day ( 7 ) ) ;
//     criteria.add ( day ( 16 ) ) ;
//     criteria.add ( day ( 22 ) ) ;

//     date first ( day ( 10 ), month::jun, 2009)  ;

//     u16t max_periods = 2;
//     i8t at_each = 1;

//     s << "Confirming: "
//       << "starting at " << first << ", for "
//       << max_periods << " periods, "
//       << "at each " << static_cast<i16t>( at_each ) << " month(s) \n";

//     (*print)(s.str());
//     s.str( "" ) ;

//     monthly_recurrence<date, monthly_by_day<date><date> > mr;

//     list<date> ds = mr.generate ( first, max_periods, at_each, criteria ) ; 

//     s << "The sequence generated:\n";
    
//     for ( list<date>::const_iterator i = ds.begin( ) ;
// 	  i != ds.end( ) ;
// 	  ++i ) {
// 	s << *i << " ";
//     }
//     s << endl << endl;
    
//     (*print)(s.str());
//     s.str ( "" ) ;
    

//     list<date> goal;
//     goal.push_back ( date ( day ( 16 ) , month::jun, 2009 ) );
//     goal.push_back ( date ( day ( 22 ) , month::jun, 2009 ) );
//     goal.push_back ( date ( day ( 04 ) , month::jul, 2009 ) );
//     goal.push_back ( date ( day ( 07 ) , month::jul, 2009 ) );
//     goal.push_back ( date ( day ( 16 ) , month::jul, 2009 ) );
//     goal.push_back ( date ( day ( 22 ) , month::jul, 2009 ) );

//     if ( goal != ds )  {
// 	s << "Generated list is not correct. That's what we wanted:\n";
// 	for ( list<date>::const_iterator i = goal.begin( ) ;
// 	      i != goal.end( ) ;
// 	      ++i ) {
// 	    s << *i << " ";
// 	}
// 	s << endl << endl;
// 	(*print)(s.str());
	
// 	throw fault ( create_fault ( date,
// 				     date::date::error_processing_date ) ) ;
//     }

//     s << "Generated list is correct!!" << endl;
//     (*print)(s.str());
// }

// // **************************************
// // t300003

// t300003::
// t300003 () :
//     tenacitas::test("t300003",
// 		    "Tries to create a sequence of dates using a "
// 		    "tenacitas::monthly_by_day<date> where the days are 4, 7, "
// 		    "16, 22, the first date is 2009.06.19, every month, for two "
// 		    "months") {}

// t300003::
// ~t300003() {}

// void 
// t300003::
// operator ( ) ( ptr<tenacitas::test_printer> print )
//     throw ( fault ) {

//     ostringstream s;

//     

//     monthly_by_day<date> criteria ( monthly_by_day<date>::create_anyway,
// 		      monthly_by_day<date>::create_anyway,
// 		      monthly_by_day<date>::dont_create,
// 		      monthly_by_day<date>::dont_create,
// 		      list<date> ( ) ) ;


//     criteria.add ( day ( 4 ) ) ;
//     criteria.add ( day ( 7 ) ) ;
//     criteria.add ( day ( 16 ) ) ;
//     criteria.add ( day ( 22 ) ) ;

//     date first ( day ( 19 ), month::jun, 2009)  ;

//     u16t max_periods = 2;
//     i8t at_each = 1;

//     s << "Confirming: "
//       << "starting at " << first << ", for "
//       << max_periods << " periods, "
//       << "at each " << static_cast<i16t>( at_each ) << " month(s) \n";

//     (*print)(s.str());
//     s.str( "" ) ;

//     monthly_recurrence<date, monthly_by_day<date><date> > mr;

//     list<date> ds = mr.generate ( first, max_periods, at_each, criteria ) ; 

//     s << "The sequence generated:\n";
    
//     for ( list<date>::const_iterator i = ds.begin( ) ;
// 	  i != ds.end( ) ;
// 	  ++i ) {
// 	s << *i << " ";
//     }
//     s << endl << endl;
    
//     (*print)(s.str());
//     s.str ( "" ) ;
    

//     list<date> goal;
//     goal.push_back ( date ( day ( 22 ) , month::jun, 2009 ) );
//     goal.push_back ( date ( day ( 04 ) , month::jul, 2009 ) );
//     goal.push_back ( date ( day ( 07 ) , month::jul, 2009 ) );
//     goal.push_back ( date ( day ( 16 ) , month::jul, 2009 ) );
//     goal.push_back ( date ( day ( 22 ) , month::jul, 2009 ) );

//     if ( goal != ds )  {
// 	s << "Generated list is not correct. That's what we wanted:\n";
// 	for ( list<date>::const_iterator i = goal.begin( ) ;
// 	      i != goal.end( ) ;
// 	      ++i ) {
// 	    s << *i << " ";
// 	}
// 	s << endl << endl;
// 	(*print)(s.str());
	
// 	throw fault ( create_fault ( date,
// 				     date::date::error_processing_date ) ) ;
//     }

//     s << "Generated list is correct!!" << endl;
//     (*print)(s.str());
// }

// // **************************************
// // t300004

// t300004::
// t300004 () :
//     tenacitas::test("t300004",
// 		    "Tries to create a sequence of dates using a "
// 		    "tenacitas::monthly_by_day<date> where the days are 4, 7, "
// 		    "16, 22, the first date is 2009.06.04, every month, for two "
// 		    "months") {}

// t300004::
// ~t300004() {}

// void 
// t300004::
// operator ( ) ( ptr<tenacitas::test_printer> print )
//     throw ( fault ) {

//     ostringstream s;

//     

//     monthly_by_day<date> criteria ( monthly_by_day<date>::create_anyway,
// 		      monthly_by_day<date>::create_anyway,
// 		      monthly_by_day<date>::dont_create,
// 		      monthly_by_day<date>::dont_create,
// 		      list<date> ( ) ) ;



//     criteria.add ( day ( 4 ) ) ;
//     criteria.add ( day ( 7 ) ) ;
//     criteria.add ( day ( 16 ) ) ;
//     criteria.add ( day ( 22 ) ) ;

//     date first ( day ( 04 ), month::jun, 2009)  ;

//     u16t max_periods = 2;
//     i8t at_each = 1;

//     s << "Confirming: "
//       << "starting at " << first << ", for "
//       << max_periods << " periods, "
//       << "at each " << static_cast<i16t>( at_each ) << " month(s) \n";

//     (*print)(s.str());
//     s.str( "" ) ;

//     monthly_recurrence<date, monthly_by_day<date><date> > mr;

//     list<date> ds = mr.generate ( first, max_periods, at_each, criteria ) ; 

//     s << "The sequence generated:\n";
    
//     for ( list<date>::const_iterator i = ds.begin( ) ;
// 	  i != ds.end( ) ;
// 	  ++i ) {
// 	s << *i << " ";
//     }
//     s << endl << endl;
    
//     (*print)(s.str());
//     s.str ( "" ) ;
    

//     list<date> goal;
//     goal.push_back ( date ( day ( 04 ) , month::jun, 2009 ) );
//     goal.push_back ( date ( day ( 07 ) , month::jun, 2009 ) );
//     goal.push_back ( date ( day ( 16 ) , month::jun, 2009 ) );
//     goal.push_back ( date ( day ( 22 ) , month::jun, 2009 ) );
//     goal.push_back ( date ( day ( 04 ) , month::jul, 2009 ) );
//     goal.push_back ( date ( day ( 07 ) , month::jul, 2009 ) );
//     goal.push_back ( date ( day ( 16 ) , month::jul, 2009 ) );
//     goal.push_back ( date ( day ( 22 ) , month::jul, 2009 ) );

//     if ( goal != ds )  {
// 	s << "Generated list is not correct. That's what we wanted:\n";
// 	for ( list<date>::const_iterator i = goal.begin( ) ;
// 	      i != goal.end( ) ;
// 	      ++i ) {
// 	    s << *i << " ";
// 	}
// 	s << endl << endl;
// 	(*print)(s.str());
	
// 	throw fault ( create_fault ( date,
// 				     date::date::error_processing_date ) ) ;
//     }

//     s << "Generated list is correct!!" << endl;
//     (*print)(s.str());
// }


// // **************************************
// // t300005

// t300005::
// t300005 () :
//     tenacitas::test("t300005",
// 		    "Tries to create a sequence of dates using a "
// 		    "tenacitas::monthly_by_day<date> where the days are 4, 7, "
// 		    "16, 22, the first date is 2009.06.07, every month, for two "
// 		    "months") {}

// t300005::
// ~t300005() {}

// void 
// t300005::
// operator ( ) ( ptr<tenacitas::test_printer> print )
//     throw ( fault ) {

//     ostringstream s;

//     

//     monthly_by_day<date> criteria ( monthly_by_day<date>::create_anyway,
// 		      monthly_by_day<date>::create_anyway,
// 		      monthly_by_day<date>::dont_create,
// 		      monthly_by_day<date>::dont_create,
// 		      list<date> ( ) ) ;


//     criteria.add ( day ( 4 ) ) ;
//     criteria.add ( day ( 7 ) ) ;
//     criteria.add ( day ( 16 ) ) ;
//     criteria.add ( day ( 22 ) ) ;

//     date first ( day ( 07 ), month::jun, 2009)  ;

//     u16t max_periods = 2;
//     i8t at_each = 1;

//     s << "Confirming: "
//       << "starting at " << first << ", for "
//       << max_periods << " periods, "
//       << "at each " << static_cast<i16t>( at_each ) << " month(s) \n";

//     (*print)(s.str());
//     s.str( "" ) ;

//     monthly_recurrence<date, monthly_by_day<date><date> > mr;

//     list<date> ds = mr.generate ( first, max_periods, at_each, criteria ) ; 

//     s << "The sequence generated:\n";
    
//     for ( list<date>::const_iterator i = ds.begin( ) ;
// 	  i != ds.end( ) ;
// 	  ++i ) {
// 	s << *i << " ";
//     }
//     s << endl << endl;
    
//     (*print)(s.str());
//     s.str ( "" ) ;
    

//     list<date> goal;
//     goal.push_back ( date ( day ( 07 ) , month::jun, 2009 ) );
//     goal.push_back ( date ( day ( 16 ) , month::jun, 2009 ) );
//     goal.push_back ( date ( day ( 22 ) , month::jun, 2009 ) );
//     goal.push_back ( date ( day ( 04 ) , month::jul, 2009 ) );
//     goal.push_back ( date ( day ( 07 ) , month::jul, 2009 ) );
//     goal.push_back ( date ( day ( 16 ) , month::jul, 2009 ) );
//     goal.push_back ( date ( day ( 22 ) , month::jul, 2009 ) );

//     if ( goal != ds )  {
// 	s << "Generated list is not correct. That's what we wanted:\n";
// 	for ( list<date>::const_iterator i = goal.begin( ) ;
// 	      i != goal.end( ) ;
// 	      ++i ) {
// 	    s << *i << " ";
// 	}
// 	s << endl << endl;
// 	(*print)(s.str());
	
// 	throw fault ( create_fault ( date,
// 				     date::date::error_processing_date ) ) ;
//     }

//     s << "Generated list is correct!!" << endl;
//     (*print)(s.str());
// }

// // **************************************
// // t300006

// t300006::
// t300006 () :
//     tenacitas::test("t300006",
// 		    "Tries to create a sequence of dates using a "
// 		    "tenacitas::monthly_by_day<date> where the days are 4, 7, "
// 		    "16, 22, the first date is 2009.06.16, every month, for two "
// 		    "months") {}

// t300006::
// ~t300006() {}

// void 
// t300006::
// operator ( ) ( ptr<tenacitas::test_printer> print )
//     throw ( fault ) {

//     ostringstream s;

//     

//     monthly_by_day<date> criteria ( monthly_by_day<date>::create_anyway,
// 		      monthly_by_day<date>::create_anyway,
// 		      monthly_by_day<date>::dont_create,
// 		      monthly_by_day<date>::dont_create,
// 		      list<date> ( ) ) ;


//     criteria.add ( day ( 4 ) ) ;
//     criteria.add ( day ( 7 ) ) ;
//     criteria.add ( day ( 16 ) ) ;
//     criteria.add ( day ( 22 ) ) ;

//     date first ( day ( 16 ), month::jun, 2009)  ;

//     u16t max_periods = 2;
//     i8t at_each = 1;

//     s << "Confirming: "
//       << "starting at " << first << ", for "
//       << max_periods << " periods, "
//       << "at each " << static_cast<i16t>( at_each ) << " month(s) \n";

//     (*print)(s.str());
//     s.str( "" ) ;

//     monthly_recurrence<date, monthly_by_day<date><date> > mr;

//     list<date> ds = mr.generate ( first, max_periods, at_each, criteria ) ; 

//     s << "The sequence generated:\n";
    
//     for ( list<date>::const_iterator i = ds.begin( ) ;
// 	  i != ds.end( ) ;
// 	  ++i ) {
// 	s << *i << " ";
//     }
//     s << endl << endl;
    
//     (*print)(s.str());
//     s.str ( "" ) ;
    

//     list<date> goal;
//     goal.push_back ( date ( day ( 16 ) , month::jun, 2009 ) );
//     goal.push_back ( date ( day ( 22 ) , month::jun, 2009 ) );
//     goal.push_back ( date ( day ( 04 ) , month::jul, 2009 ) );
//     goal.push_back ( date ( day ( 07 ) , month::jul, 2009 ) );
//     goal.push_back ( date ( day ( 16 ) , month::jul, 2009 ) );
//     goal.push_back ( date ( day ( 22 ) , month::jul, 2009 ) );

//     if ( goal != ds )  {
// 	s << "Generated list is not correct. That's what we wanted:\n";
// 	for ( list<date>::const_iterator i = goal.begin( ) ;
// 	      i != goal.end( ) ;
// 	      ++i ) {
// 	    s << *i << " ";
// 	}
// 	s << endl << endl;
// 	(*print)(s.str());
	
// 	throw fault ( create_fault ( date,
// 				     date::date::error_processing_date ) ) ;
//     }

//     s << "Generated list is correct!!" << endl;
//     (*print)(s.str());
// }

// // **************************************
// // t300007

// t300007::
// t300007 () :
//     tenacitas::test("t300007",
// 		    "Tries to create a sequence of dates using a "
// 		    "tenacitas::monthly_by_day<date> where the days are 4, 7, "
// 		    "16, 22, the first date is 2009.06.22, every month, for two "
// 		    "months") {}

// t300007::
// ~t300007() {}

// void 
// t300007::
// operator ( ) ( ptr<tenacitas::test_printer> print )
//     throw ( fault ) {

//     ostringstream s;

//     

//     monthly_by_day<date> criteria ( monthly_by_day<date>::create_anyway,
// 		      monthly_by_day<date>::create_anyway,
// 		      monthly_by_day<date>::dont_create,
// 		      monthly_by_day<date>::dont_create,
// 		      list<date> ( ) ) ;


//     criteria.add ( day ( 4 ) ) ;
//     criteria.add ( day ( 7 ) ) ;
//     criteria.add ( day ( 16 ) ) ;
//     criteria.add ( day ( 22 ) ) ;

//     date first ( day ( 22 ), month::jun, 2009)  ;

//     u16t max_periods = 2;
//     i8t at_each = 1;

//     s << "Confirming: "
//       << "starting at " << first << ", for "
//       << max_periods << " periods, "
//       << "at each " << static_cast<i16t>( at_each ) << " month(s) \n";

//     (*print)(s.str());
//     s.str( "" ) ;

//     monthly_recurrence<date, monthly_by_day<date><date> > mr;

//     list<date> ds = mr.generate ( first, max_periods, at_each, criteria ) ; 

//     s << "The sequence generated:\n";
    
//     for ( list<date>::const_iterator i = ds.begin( ) ;
// 	  i != ds.end( ) ;
// 	  ++i ) {
// 	s << *i << " ";
//     }
//     s << endl << endl;
    
//     (*print)(s.str());
//     s.str ( "" ) ;
    

//     list<date> goal;
//     goal.push_back ( date ( day ( 22 ) , month::jun, 2009 ) );
//     goal.push_back ( date ( day ( 04 ) , month::jul, 2009 ) );
//     goal.push_back ( date ( day ( 07 ) , month::jul, 2009 ) );
//     goal.push_back ( date ( day ( 16 ) , month::jul, 2009 ) );
//     goal.push_back ( date ( day ( 22 ) , month::jul, 2009 ) );

//     if ( goal != ds )  {
// 	s << "Generated list is not correct. That's what we wanted:\n";
// 	for ( list<date>::const_iterator i = goal.begin( ) ;
// 	      i != goal.end( ) ;
// 	      ++i ) {
// 	    s << *i << " ";
// 	}
// 	s << endl << endl;
// 	(*print)(s.str());
	
// 	throw fault ( create_fault ( date,
// 				     date::date::error_processing_date ) ) ;
//     }

//     s << "Generated list is correct!!" << endl;
//     (*print)(s.str());
// }

// // **************************************
// // t300008

// t300008::
// t300008 () :
//     tenacitas::test("t300008",
// 		    "Tries to create a sequence of dates using a "
// 		    "tenacitas::monthly_by_day<date> where the days are 4, 7, "
// 		    "16, 22, the first date is 2009.06.24, every month, for two "
// 		    "months") {}

// t300008::
// ~t300008() {}

// void 
// t300008::
// operator ( ) ( ptr<tenacitas::test_printer> print )
//     throw ( fault ) {

//     ostringstream s;

//     

//     monthly_by_day<date> criteria ( monthly_by_day<date>::create_anyway,
// 		      monthly_by_day<date>::create_anyway,
// 		      monthly_by_day<date>::dont_create,
// 		      monthly_by_day<date>::dont_create,
// 		      list<date> ( ) ) ;


//     criteria.add ( day ( 4 ) ) ;
//     criteria.add ( day ( 7 ) ) ;
//     criteria.add ( day ( 16 ) ) ;
//     criteria.add ( day ( 22 ) ) ;

//     date first ( day ( 24 ), month::jun, 2009)  ;

//     u16t max_periods = 2;
//     i8t at_each = 1;

//     s << "Confirming: "
//       << "starting at " << first << ", for "
//       << max_periods << " periods, "
//       << "at each " << static_cast<i16t>( at_each ) << " month(s) \n";

//     (*print)(s.str());
//     s.str( "" ) ;

//     monthly_recurrence<date, monthly_by_day<date><date> > mr;

//     list<date> ds = mr.generate ( first, max_periods, at_each, criteria ) ; 

//     s << "The sequence generated:\n";
    
//     for ( list<date>::const_iterator i = ds.begin( ) ;
// 	  i != ds.end( ) ;
// 	  ++i ) {
// 	s << *i << " ";
//     }
//     s << endl << endl;
    
//     (*print)(s.str());
//     s.str ( "" ) ;
    

//     list<date> goal;
//     goal.push_back ( date ( day ( 04 ) , month::jul, 2009 ) );
//     goal.push_back ( date ( day ( 07 ) , month::jul, 2009 ) );
//     goal.push_back ( date ( day ( 16 ) , month::jul, 2009 ) );
//     goal.push_back ( date ( day ( 22 ) , month::jul, 2009 ) );

//     if ( goal != ds )  {
// 	s << "Generated list is not correct. That's what we wanted:\n";
// 	for ( list<date>::const_iterator i = goal.begin( ) ;
// 	      i != goal.end( ) ;
// 	      ++i ) {
// 	    s << *i << " ";
// 	}
// 	s << endl << endl;
// 	(*print)(s.str());
	
// 	throw fault ( create_fault ( date,
// 				     date::date::error_processing_date ) ) ;
//     }

//     s << "Generated list is correct!!" << endl;
//     (*print)(s.str());
// }
